package com.yuebao.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.yuebao.api.UserAccountService;
import com.yuebao.enumeration.ResponseCodeEnum;
import com.yuebao.model.pojo.UserAccount;
import com.yuebao.result.EntityResponse;
import com.yuebao.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("/userAccount")
public class UserAccountController {

    @Resource
    UserAccountService userAccountService;

    //userAccountService.query().eq("user_id",preOrder.getUserId()).one();
    @GetMapping("/getUserAccountById/{userId}")
    public EntityResponse<UserAccount> getUserAccountByID(@PathVariable(value = "userId") Long userId){
        UserAccount userAccount=userAccountService.query().eq("user_id",userId).one();
        log.info("用户信息查询{}", JsonUtils.writeValueAsString(userAccount));
        return new EntityResponse<>(ResponseCodeEnum.SUCCESS,"用户信息查询成功",userAccount);
    }
}
